package com.edooteach.entity.user;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;

/**
 * 
 * @author mohanlan
 *
 */
@Entity
@Table(name = "weapp_notice_ticket")
public class WeappNoticeTicket {

    @Id
    @GeneratedValue
    private Long id;
    
    /**
     * 通知ticket的值
     */
    private String value;
    
    /**
     * ticket所属人
     */
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
    @JsonIdentityReference(alwaysAsId=true)
    private User user;
    
    /**
     * ticket是否被使用过
     */
    @Column(name = "is_used")
    private boolean used;
    
    /**
     * ticket创建时间
     */
    private Date createTime;
    
    @Column(name = "is_disabled")
    private boolean disabled;
    
    public WeappNoticeTicket() {
    }
    
    /**
     * 
     * @return
     */
    public WeappNoticeTicket initliaze() {
        this.createTime = new Date();
        this.used = false;
        this.createTime = new Date();
        this.disabled = false;
        
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the value
     */
    public String getValue() {
        return value;
    }

    /**
     * @return the user
     */
    public User getUser() {
        return user;
    }


    /**
     * @return the used
     */
    public boolean isUsed() {
        return used;
    }

    /**
     * @return the createTime
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * @return the disabled
     */
    public boolean isDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param value the value to set
     */
    public void setValue(String value) {
        this.value = value;
    }

    /**
     * @param user the user to set
     */
    public void setUser(User user) {
        this.user = user;
    }

    /**
     * @param used the used to set
     */
    public void setUsed(boolean used) {
        this.used = used;
    }

    /**
     * @param createTime the createTime to set
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(boolean disabled) {
        this.disabled = disabled;
    }
}
